This is killing me... I have a file in a directory (filename). All I wanna do is open it, and paste a string into cell(1,1). I can't for the life of me figure out why this doesn't work:
OleAutoObj wbs
OleAutoObj wb
OleAutoObj ws
OleAutoObj objCell
OleAutoArgs args = create
OleAutoObj objFont
void openExcel()
{
string filename = "C:\Temp\file.xls"
OleAutoObj ex = oleCreateAutoObject "Excel.Application"
olePut(ex,"Visible",true)
oleGet(ex,"Workbooks", wbs)
put (args,filename"")
oleMethod(wbs,"Open",args,wb)
oleGet (ex, "Worksheets", args, ws)
}
void pasteString (int y, int x, string s)
{
clear args
put (args, y)
put (args, x)
oleGet (ws, "Cells", args, objCell)
clear args
put (args, objCell)
copyToClipboard s
print oleMethod (ws, "Paste",args)
}
openExcel()
pasteString (1,1, tempStringOf tempOutput)
delete tempOutput
moheganburnerIII - Fri Oct 14 17:07:39 EDT 2011 |
Re: Pasting to an existing Excel file |
Re: Pasting to an existing Excel file True, but the string gets pasted just fine when I switch a couple things around and have it open a NEW Excel wb and paste it there.
currMod = current Module
Object othero
Buffer tempO = create
for othero in entire currMod do
{
string oi = identifier othero ""
string ot = othero."Object Text" ""
tempO += oi "\t" ot
tempO += "\n"
}
OleAutoObj wbs
OleAutoObj wb
OleAutoObj ws
OleAutoObj objCell
OleAutoArgs args = create
OleAutoObj objFont
void openExcel()
{
OleAutoObj ex = oleCreateAutoObject "Excel.Application"
oleGet (ex, "Workbooks", wbs)
oleMethod (wbs, "Add", args, wb)
olePut(ex, "Visible", true)
put(args, 1)
oleGet (ex, "Worksheets", args, ws)
}
void pasteString (int y, int x, string s)
{
clear args
put (args, y)
put (args, x)
oleGet (ws, "Cells", args, objCell)
clear args
put (args, objCell)
copyToClipboard s
print oleMethod (ws, "Paste",args)
}
openExcel()
pasteString (1,1, tempStringOf tempO)
delete tempO
}
void openExcel()
{
string filename = "C:\Temp\file.xls"
OleAutoObj ex = oleCreateAutoObject "Excel.Application"
olePut(ex,"Visible",true)
oleGet(ex,"Workbooks", wbs)
put (args,filename"")
oleMethod(wbs,"Open",args,wb)
oleGet (ex, "Worksheets", args, ws)
}
|
Re: Pasting to an existing Excel file Solved my own problem by changing
void openExcel()
{
string filename = "C:\Temp\file.xls"
OleAutoObj ex = oleCreateAutoObject "Excel.Application"
olePut(ex,"Visible",true)
oleGet(ex,"Workbooks", wbs)
put (args,filename"")
oleMethod(wbs,"Open",args,wb)
oleGet (ex, "Worksheets", args, ws)
}
void openExcel()
{
string filename = "C:\Temp\file.xls"
OleAutoObj ex = oleCreateAutoObject "Excel.Application"
olePut(ex,"Visible",true)
oleGet(ex,"Workbooks", wbs)
put (args,filename"")
oleMethod(wbs,"Open",args,wb)
oleGet (ex, "ActiveSheet", ws)
}
|